package com.zero.qth.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zero.qth.service.IDriverService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.zero.qth.mapper.DriverMapper;
import com.zero.qth.domain.Driver;

/**
 * 司机列表Service业务层处理
 * 
 * @author cai-xu-kun
 * @date 2025-08-02
 */
@Service
@RequiredArgsConstructor
public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService {

    private final DriverMapper driverMapper;

    /**
     * 查询司机列表分页
     *
     * @param driver 司机列表
     * @param p 分页数据
     * @return 司机列表
     */
    @Override
    public Page<Driver> selectDriverListPage(Driver driver, Page<Driver> p) {
        return driverMapper.selectDriverListPage(driver, p);
    }

    /**
     * 查询司机列表
     * 
     * @param id 司机列表主键
     * @return 司机列表
     */
    @Override
    public Driver selectDriverById(Long id) {
        return driverMapper.selectDriverById(id);
    }

    /**
     * 查询司机列表列表
     * 
     * @param driver 司机列表
     * @return 司机列表
     */
    @Override
    public List<Driver> selectDriverList(Driver driver) {
        return driverMapper.selectDriverList(driver);
    }

    /**
     * 新增司机列表
     * 
     * @param driver 司机列表
     * @return 结果
     */
    @Override
    public int insertDriver(Driver driver) {
        return driverMapper.insertDriver(driver);
    }

    /**
     * 修改司机列表
     * 
     * @param driver 司机列表
     * @return 结果
     */
    @Override
    public int updateDriver(Driver driver) {
        return driverMapper.updateDriver(driver);
    }

    /**
     * 批量删除司机列表
     * 
     * @param ids 需要删除的司机列表主键
     * @return 结果
     */
    @Override
    public int deleteDriverByIds(Long[] ids) {
        return driverMapper.deleteDriverByIds(ids);
    }

    /**
     * 删除司机列表信息
     * 
     * @param id 司机列表主键
     * @return 结果
     */
    @Override
    public int deleteDriverById(Long id) {
        return driverMapper.deleteDriverById(id);
    }

    @Override
    public void updateNoyiceReadToFalse() {
        LambdaUpdateWrapper<Driver> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(Driver::getIsNoticeRead, false);
        baseMapper.update(null, updateWrapper);
    }
}
